# 引入表单类
from django import forms
# 引入文章模型
from .models import ArticlePost,ArticleColumn
from mdeditor.fields import MDTextFormField

# 写文章的表单类
class ArticlePostForm(forms.ModelForm):
    body = MDTextFormField()
    column = forms.ModelChoiceField(
        queryset=ArticleColumn.objects.all(),
        required=False,
        label='栏目',
        widget=forms.Select(attrs={'class': 'form-control'})
        )
    class Meta:
        # 指明数据模型来源
        model = ArticlePost
        # 定义表单包含的字段
        fields = ('title', 'body', 'tags', 'column','avatar')